axios.defaults.baseURL = "http://cba.itlike.com/public/index.php?s=/api";

let tel = document.querySelector("[name=telNumber");
let yzm = document.querySelector("[name=yzm]");
let text = document.querySelector("[name=text]");
let but = document.querySelector("[name=but]");
let btn = document.querySelector("#btn");
// 图形验证码
axios.get("/captcha/image").then(({ data: { data } }) => {
  // console.log(window.atob(data.base64));
  document.querySelector(".base img").src = data.base64;
  console.log(data);
  //   获取短信验证码
  but.addEventListener("click", () => {
    console.log(111);
    axios
      .post("/captcha/sendSmsCaptcha", {
        form: {
          mobile: tel.value,
          captchaKey: data.key,
          captchaCode: yzm.value,
        },
      })
      .then((res) => {
        console.log(res);
      });
  });
  //   登录
  btn.addEventListener("click", () => {
    axios
      .post("/passport/login", {
        form: {
          isParty: false,
          mobile: tel.value,
          partyData: {},
          smsCode: text.value,
        },
      })
      .then((res) => {
        console.log(res);
      })
      .catch((error) => {
        console.log(error);
      });
  });
});
